<?php

namespace Modules\Asset;

use Modules\Asset\Entities\WithdrawRecord;

class Cron
{
	public function handle($schedule)
	{
		$that = $this;
		$schedule->call(function() use ($that) {
			try {
				$that->everyMinute();
			}
			catch (\Throwable $e) {
                \Log::error('cron任务异常');
                \Log::error($e->getMessage());
            }
		})->everyMinute();
	}

	public function everyMinute()
	{
		// 自动关闭订单
		$list = WithdrawRecord::where('auto_pay_status', 4)->get();

		foreach ($list as $item) {
			$item->startAutoPay();
		}
	}
}